package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.pojo.Login;
import com.itheima.service.LoginService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;


/**
 * @author 林晓伟
 */
@RestController
@RequestMapping("/user")
public class LoginController {

    @Resource
    private LoginService loginService;

    /**
     * F02-登录接口
     * @param login 手机号和验证码
     */
    @PostMapping("/login")
    public R a(@RequestBody Login login){
        Login a = loginService.a(login);
        if (a != null){
            return R.success(a);
        }
        return R.error("登录失败");
    }

    /**
     * F03-登出
     */
    @PostMapping("/loginout")
    public R d(){
        return R.success("退出");
    }

}
